package com.yesep.learn.design.structural.adapter;

import com.yesep.learn.design.common.*;
import com.yesep.learn.design.common.util.*;

public class MediaAdapter {
    IMediaPlayer player;

    public MediaAdapter(IMediaPlayer adapter) throws Exception {
        player = adapter;
    }

    public MediaAdapter(Class<? extends IMediaPlayer> cls) throws Exception {
        player = Util.getInstance(cls);
    }

    public void play(String fileName) {
        player.play(fileName);
    }

    public void pause() {
        player.pause();
    }

    public void stop() {
        player.stop();
    }
}
